#ifndef KEYCONTROLLABLEMENU_H
#define KEYCONTROLLABLEMENU_H

#include <QWidget>
#include "button.h"
#include "keybindings.h"
#include "volumedisplay.h"
#include "windowmanager.h"

class KeyControllableMenu : public QWidget
{
    Q_OBJECT
    typedef  QList<Button *> ButtonList;

public:
    KeyControllableMenu(QWidget * parent=0);
    static VolumeDisplay * volumeDisplay;
    void addRow(Button * button);
    void addRow(QList<Button *> * buttons);
    void setActive(Button * button);
    void setStyleSheets(QString selected="",QString unselected="", QString inactiveSelected="");
    Button * getCurrentButton();
    Button * findButton(QObject * item);

    void clearRows();
    bool active;
    void removeButton(Button * button);
    void setCircularVertically(bool circular);
    void setCircularHorizontally(bool circular);
    void addButtonBefore(Button * toAdd, Button * otherButton);
    static void displayPopup(QWidget * widget, int x, int y);
    static void displayPopup(QWidget * widget, QWidget * relativeTo,int x, int y);
    void addWidget(QWidget * widget);
public slots:
    void buttonEntered(Button * button);
    void buttonSelected();
    void buttonRightClicked();
    void keyPressEvent ( QKeyEvent * event );
    virtual void show();
    void deactivate();
    void activate();
protected:
    void wheelEvent ( QWheelEvent * event );
signals:
    void keyPressed(QKeyEvent * event);
    void escapeTop();
    void escapeBottom();
    void escapeLeft();
    void escapeRight();
private:

    QList<ButtonList *> * rows;
    int currentRow;
    int currentColumn;
    QString selectedStyleSheet;
    QString unSelectedStyleSheet;
    QString inactiveSelectedStyleSheet;
    bool isCircularVertically, isCircularHorizontally;    

};

#endif // KEYCONTROLLABLEMENU_H
